package com.xinqizhi.service.impl;

import com.xinqizhi.entity.XqzSchool;
import com.xinqizhi.mapper.XqzSchoolMapper;
import com.xinqizhi.service.XqzSchoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

@Service
public class XqzSchoolServiceImpl  implements XqzSchoolService {
    @Autowired
    private XqzSchoolMapper schoolMapper;
    /**
     * 添加一所学校信息
     *
     * @param schoolStaffId
     * @param schoolAddr
     * @return
     */
    @Override
    public Boolean addASchool(Integer schoolStaffId, String schoolAddr) {
        XqzSchool school = new XqzSchool();
        school.setSchoolStaffId(schoolStaffId);
        school.setSchoolAddr(schoolAddr);
        school.setSchoolMaster("自动从用户数据表中读取");
        school.setSchoolStatus(1);
        school.setSchoolCreateDt(new Timestamp(new Date().getTime()));
        Boolean aBoolean = schoolMapper.insertData(school);
        return aBoolean;
    }

    /**
     * 获取所有学校信息
     *
     * @return
     */
    @Override
    public List<XqzSchool> getSchoolList() {
        return schoolMapper.getAllData();
    }

    /**
     * 根据ID查询学校
     *
     * @param schoolId
     * @return
     */
    @Override
    public XqzSchool getSchoolById(Integer schoolId) {
        List<XqzSchool> data = schoolMapper.getData(schoolId);
        return data.get(0);
    }

    /**
     * 修改学校信息
     *
     * @param school
     * @return
     */
    @Override
    public Integer updateSchool(XqzSchool school) {
        school.setSchoolCreateDt(new Timestamp(new Date().getTime()));
        return schoolMapper.updateData(school);
    }

    /**
     * 删除一所分校
     *
     * @param schId
     * @return
     */
    @Override
    public Integer del_School(Integer schId) {
        return schoolMapper.deleteData(schId);
    }
    /**
	* 已经实现基础的增、删、改、查、批量删除、批量修改、批量插入，
	*/


	/**
	* 需要新功能可以在此实现自定义方法
	*/

}
